import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material

ApplicationWindow {
    width: column.width + 100
    height: column.height + 50
    visible: true
    title: qsTr("PUBG降低即时音量")

    Material.theme: Material.Dark
    Material.accent: Material.Amber

    function onClosing(close){
        autoKeyPress.exited();
        close.accepted = closing
    }

    Column{
        id: column
        anchors.centerIn: parent
        anchors.topMargin: 10

        CheckBox{
            id: checkBox
            // anchors.centerIn: parent
            text: "开枪降低音量"

            onClicked: {
                autoKeyPress.setBChecked(checked);
            }
        }

        Text {
            color: "white"
            text: qsTr("检测左键长按时间阈值:")
        }

        Slider{
            id: slider
            from: 100
            to: 1000
            value: 200
            enabled: !checkBox.checked
            onValueChanged: {
                if (value != spinBox.value)
                {
                    spinBox.value = value;
                }
                autoKeyPress.setThreshold(value);
            }
        }

        SpinBox{
            id: spinBox
            height: slider.height
            from: 100
            to: 1000
            value: 200
            editable: true
            enabled: !checkBox.checked
            onValueChanged: {
                if (value != slider.value)
                {
                    slider.value = value;
                }
                autoKeyPress.setThreshold(value);
            }
        }
    }
}
